package com.xmindguoguo.boot.modular.monitor.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.xmindguoguo.boot.common.constant.GlobalConstant;
import com.xmindguoguo.boot.core.BaseController;
import com.xmindguoguo.boot.modular.monitor.model.TSystemSessionModel;
import com.xmindguoguo.boot.modular.monitor.service.ITSystemSessionService;
import com.xmindguoguo.boot.util.json.JsonResult;

/**
 * 控制器 //先暂时全部小写，后面写个方法注册进来，调整大小写
 * 
 * @author xmind-果果
 * @Date 2019-02-27 10:48
 */

@Controller
@RequestMapping("/tSystemSession")
public class TSystemSessionController extends BaseController {

    // 所属子模块名称+当前功能名称
    private String PREFIX = "/system/tSystemSession/";

    @Autowired
    private ITSystemSessionService systemSessionService;

    /**
     * 跳转列表页
     */
    @RequestMapping("toTSystemSessionList")
    public String toTSystemSessionList() {
        return PREFIX + "tSystemSessionList";
    }

    /**
     * 查询列表数据 表格 数据时用，不用删除
     */
    @RequestMapping("tSystemSessionList")
    @ResponseBody
    public Object tSystemSessionList(TSystemSessionModel model, @RequestParam(value = "page", required = false) Integer current,
            @RequestParam(value = "limit", required = false) Integer size) {
        Wrapper<TSystemSessionModel> wrapper = new EntityWrapper<>();
        /* if (ToolUtil.isNotEmpty(model.getAccount())) {
            wrapper.like("account", model.getAccount());
        }
        */
        wrapper.ne("status", GlobalConstant.MODEL_DEL);
        wrapper.orderBy("createTime", false);
        Page<TSystemSessionModel> page = new Page<>(current, size);
        return JsonResult.sendPage(systemSessionService.selectPage(page, wrapper)); // 跳转到列表页
    }

    // 查看详情
    @RequestMapping("toTSystemSessionDetail")
    public String toTSystemSessionDetail(Long id) {
        TSystemSessionModel model = systemSessionService.selectById(id);
        request.setAttribute("model", model);
        return PREFIX + "tSystemSessionDetail";
    }

}